package com.itheima.xmy.Demo;

import java.util.Scanner;

//按以下步骤要求编写代码：
//        4. 编写测试类，创建一个Student对象，并在try{}中调用setXxx()方法为对象属性赋值，在catch()中打印年龄错误。
public class ExceptionDemo01 {
    public static void main(String[] args) {
        Student student = new Student();
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.println("请输入您的年龄：");
            int inPutAge = scanner.nextInt();
            student.setAge(inPutAge);

            System.out.println("请输入您的性别：");
            String inPutSex = scanner.next();
            student.setSex(inPutSex);

        }
        catch (AgeException ageException) {
            ageException.printStackTrace();
        }
        catch (SexException sexException) {
            sexException.printStackTrace();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

}
